package com.dlc.beijingrfid.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import com.dlc.beijingrfid.R;
import com.dlc.beijingrfid.net.bean.MsgBean;
import com.holenzhou.pullrecyclerview.BaseRecyclerAdapter;
import com.holenzhou.pullrecyclerview.BaseViewHolder;
import java.util.List;

/**
 * Created by Administrator on 2017/7/26 0026.
 */

public class MsgAdapter extends BaseRecyclerAdapter<MsgBean.DataBean.ListBean> {
    private OnItemClickListener onItemClickListener;
    private Context context;

    public MsgAdapter(Context context, int layoutResId, List<MsgBean.DataBean.ListBean> data) {
        super(context, layoutResId, data);
        this.context=context;
    }



    @Override
    protected void convert(BaseViewHolder holder, final MsgBean.DataBean.ListBean item, final int position) {
        holder.setText(R.id.tv_title,item.title);
        holder.setText(R.id.tv_content,item.message);
        String status=item.status;
        if(TextUtils.equals(status,"0")){
            holder.setImageDrawable(R.id.iv_msg_state,context.getResources().getDrawable(R.mipmap.ic_news_02));
        }else {
            holder.setImageDrawable(R.id.iv_msg_state,context.getResources().getDrawable(R.mipmap.ic_news_03));
        }
        holder.setOnClickListener(R.id.msg_item, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onItemClickListener.onClick(position,item.id);
            }
        });


    }
    public interface OnItemClickListener {
        void onClick(int position, String id);
    }
    public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.onItemClickListener=onItemClickListener;

    }
}
